import api from '../index';
import type { ResponseData, pageParam, ResponseRowsRes } from '../index';

export interface InformationClassify {
	createTime: string;
	id: number;
	name: string;
	type: 1 | 2;
	status: 0 | 1;
	sort: number;
}
// 新闻资讯分类列表
export const getInformationClassifyList = (data: (pageParam|{isPage:false}) & { type?: 1 | 2 }) =>
	api.get<ResponseRowsRes<InformationClassify[]>>('system/api/news/category/list', {
		data,
		custom: {
			auth: false
		}
	});

export interface InformationItem {
	id: number;
	categoryId: number; //分类id
	title: string; //新闻标题
	content: string; //新闻内容
	authorName: string; //来源
	thumbnailPic: string; //图片，逗号隔开
	type: 1 | 2; // 1.平台 2.聚合
	date: string; //发布时间
	views: number; //浏览量
}
// 新闻资讯列表
export const getInformationList = (data: pageParam&{categoryId?: number | string}) =>
	api.get<ResponseRowsRes<InformationItem[]>>('system/api/news/list', {
		data,
		custom: {
			auth: false
		}
	});
// 新闻资讯详情
export const getInformationInfo = (id: number | string) =>
	api.get<ResponseData<InformationItem>>(`/system/api/news/info/${id}`, {
		custom: {
			auth: false
		}
	});
